/********************************************************
 * Filename: TclStringScanner.java
 * Author: LMU
 * Program: TUnit
 * Description: Creates the tcl scanner for syntax 
 * highlighting of strings.   
 * Revision History:
 * 20060428: Initial Revision.
 * *****************************************************/

package edu.lmu.cs.tUnit.editor;

import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.Token;

public class TclStringScanner extends RuleBasedPartitionScanner {
	
	public final static String TCL_STRING = "__tcl_string";
	public final static String TCL_COMMENT = "__tcl_comment";
	public final static String TCL_BACKSLASH = "__tcl_backslash";
	
	public TclStringScanner() {
		setPredicateRules(getRules());
	}
	
	public IPredicateRule[] getRules() {
		IToken string = new Token(TCL_STRING);
		IToken comment = new Token(TCL_COMMENT);
		IToken backslash = new Token(TCL_BACKSLASH);
		
		IPredicateRule[] rules = new IPredicateRule[3];
		
		// add rule for strings and comments
		rules[0] = new EndOfLineRule("\\", backslash);
		rules[1] = new EndOfLineRule("#", comment); 
		rules[2] = new MultiLineRule("\"", "\"", string);
		
		return rules;
	}
}
